Option Explicit

' 表物理名所在的行号，默认值=1
Private Const TABLE_PHY_NAME_ROW_NO As Integer = 1
' 列物理名所在的行号(默认值=3)
Private Const COLUMN_PHY_NAME_ROW_NO As Integer = 3
' 列类型所在的行号(默认值=4)
Private Const COLUMN_TYPE_ROW_NO As Integer = 4
' 数据起始行所在的行号(默认值=7)
Private Const DATA_START_ROW_NO As Integer = 7
' table 定义列的列号(默认值=3)
Private Const DEFINE_TITLE_COL_NO As Integer = 3
' table 物理名标题列的标题内容
Private Const TABLE_PHY_NAME_TITLE_CONTENT As String = "tableName"

Public Sub main()
    Dim wb As Workbook
    Set wb = ActiveWorkbook

    Dim form As VBComponent
    Set form = wb.VBProject.VBComponents.Item("createInsertSQLForm")

    ' ==================================================
    ' 1. 设置 form 的属性
    ' ==================================================
    With form
        .Properties("Height") = 500
        .Properties("Width") = 590
        .Properties("Caption") = "create insert sql"
    End With

    Dim ctrs As Controls
    Set ctrs = form.Designer.Controls

    ' ==================================================
    ' 2. 第一行
    ' ==================================================
    ' 1. 设置: 表物理名所在的行号(默认值=1)
    '    标题
    UtilsControl.createLabel ctrs, "tablePhyNameRowNoLabel", _
        18, 114, 24, 18, caption:="Table Phy Name RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "tablePhyNameRowNoBox", _
        24, 36, 144, 12, _
        fontSize:=12, text:=TABLE_PHY_NAME_ROW_NO, value:=TABLE_PHY_NAME_ROW_NO, tabIndex:=1

    ' 2. 设置: 列物理名所在的行号(默认值=3)
    '    标题
    UtilsControl.createLabel ctrs, "columnPhyNameRowNoLabel", _
        18, 126, 192, 18, caption:="Column Phy Name RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "columnPhyNameRowNoBox", _
        24, 36, 318, 12, _
        fontSize:=12, text:=COLUMN_PHY_NAME_ROW_NO, value:=COLUMN_PHY_NAME_ROW_NO, tabIndex:=2

    ' 3. 设置: 列类型所在的行号(默认值=4)
    '    标题
    UtilsControl.createLabel ctrs, "columnTypeRowNoLabel", _
        18, 102, 360, 18, caption:="Column Type RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "columnTypeRowNoBox", _
        24, 36, 468, 12, _
        fontSize:=12, text:=COLUMN_TYPE_ROW_NO, value:=COLUMN_TYPE_ROW_NO, tabIndex:=3

    ' ==================================================
    ' 3. 第二行
    ' ==================================================
    ' 1. 设置: 数据起始行所在的行号(默认值=7)
    '    标题
    UtilsControl.createLabel ctrs, "dataStartRowNoLabel", _
        12, 90, 24, 48, caption:="Data Start RowNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "dataStartRowNoBox", _
        24, 36, 144, 42, _
        fontSize:=12, text:=DATA_START_ROW_NO, value:=DATA_START_ROW_NO, tabIndex:=4

    ' 2. 设置: table 定义列的列号
    '    标题
    UtilsControl.createLabel ctrs, "defineTitleColNoLabel", _
        12, 90, 192, 48, caption:="Define Title ColNo", fontSize:=11

    '    输入框
    UtilsControl.createTextBox ctrs, "defineTitleColNoBox", _
        24, 36, 318, 42, _
        fontSize:=12, text:=DEFINE_TITLE_COL_NO, value:=DEFINE_TITLE_COL_NO, tabIndex:=5

    ' ==================================================
    ' 4. 第三行
    ' ==================================================
    ' 1. 设置: table 物理名标题列的标题内容
    '    标题
    UtilsControl.createLabel ctrs, "tablePhyNameTitleContentLabel", _
        18, 144, 24, 84, caption:="Table Phy Name Title Content", fontSize:=10

    '    输入框
    UtilsControl.createTextBox ctrs, "tablePhyNameTitleContentBox", _
        24, 150, 174, 78, _
        fontSize:=12, text:=TABLE_PHY_NAME_TITLE_CONTENT, value:=TABLE_PHY_NAME_TITLE_CONTENT, tabIndex:=6

    ' 2. 选项按钮: 是否需要添加 truncate sql
    UtilsControl.createCheckBox ctrs, "needTruncateBox", _
        18, 108, 342, 78, _
        caption:="Need Truncate", value:=True, _
        fontSize:=10, tabIndex:=7

    ' 3. 选项按钮: 是否需要在 insert 中添加列名
    UtilsControl.createCheckBox ctrs, "needColumnPhyNameBox", _
        18, 132, 449, 78, _
        caption:="Need ColumnPhyName", value:=True, _
        fontSize:=10, tabIndex:=8

    ' ==================================================
    ' 5. 第四行
    ' ==================================================
    ' 1. range
    '    标题
    UtilsControl.createLabel ctrs, "rangeLabel", _
        18, 42, 24, 120, caption:="Range", fontSize:=12

    '    输入框
    UtilsControl.createRefEdit ctrs, "rangeBox", _
        24, 420, 66, 120, _
        fontSize:=12, tabIndex:=9

    ' ==================================================
    ' 6. 第五行
    ' ==================================================
    ' 1. 生成某个区域内的 sql 的按钮
    UtilsControl.createButton ctrs, "createRangeBtn", _
        30, 72, 24, 144, _
        caption:="createRange", fontSize:=10, tabIndex:=10

    ' 2. 生成整个 sheet 的 sql 的按钮
    UtilsControl.createButton ctrs, "createSheetBtn", _
        30, 90, 108, 144, _
        caption:="createSheet", fontSize:=10, tabIndex:=11

    ' 3. 生成一个区域内的 truncate 的按钮
    UtilsControl.createButton ctrs, "createRangeTruncateBtn", _
        30, 90, 210, 144, _
        caption:="createRangeTruncate", fontSize:=10, tabIndex:=13

    ' 4. 生成整个 sheet 的 truncate 的按钮
    UtilsControl.createButton ctrs, "createTruncateBtn", _
        30, 90, 306, 144, _
        caption:="createTruncate", fontSize:=10, tabIndex:=12

    ' ==================================================
    ' 7. 第六行
    ' ==================================================
    ' 显示生成的 sql 的输入框
    UtilsControl.createTextBox ctrs, "resultBox", _
        186, 546, 24, 180, _
        fontSize:=9, tabIndex:=12, scrollBars:=3, multiLine:=True
End Sub
